package com.zhao.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName ConfigBean
 * @author:赵培舒
 * @date:Created in 2021/4/18 16:20
 * @Email:stevezhao@nyist.edu.cn
 * @description：配置bean到spring中
 * @version: 1.0
 */
@Configuration
public class ConfigBean {
   /**
    * @param
    * @return RestTemplate
    * @author 赵培舒
    * @date 2021/4/18 16:24
    * @Email stevezhao@nysit.edu.cn
    */
   //配置负载均衡实现RestTemplate
   //IRule
   //RoundRobinRule 轮询
   //Round
   //AvailabilityFilteringRule :会先过滤掉中断的服务~，对剩下的进行轮询

    @Bean
    @LoadBalanced  //开启负载均衡 Ribbon
    public RestTemplate getRestTemolate(){
      return new RestTemplate();
    }

}
